#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve()
{
    string s;
    cin >> s;
    
    while (1)
    {
        int sum1 = 0, sum2 = 0;
        for (int i = 0; i < s.size(); i++)
        {
            if (i & 1)
                sum1 += s[i] - '0';
            else
                sum2 += s[i] - '0';
        }
        // cout << sum1 << ' ' << sum2 << endl;
        if(sum1 == sum2){
            cout << "YES" << endl;
            return;
        }
        int t = abs(sum1 - sum2);
        s = to_string(t);
        // cout << s << endl;
        if(s.size() == 1){
             cout << "NO" << endl;
             return;
        }
    }
}

int main()
{
    int t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}